<?php
/**
 * 菜单顶部用户信息。
 * @link https://www.kancloud.cn/cleverstone/ymb2
 * @copyright Copyright (c) 2020 Yii Manager Software LLC
 */

use builder\helper\App;
use builder\helper\Url;
use common\models\SystemGroupService;

/* @var $this \yii\web\View */
/* @var \common\models\Admin $identity */
$identity = Yii::$app->user->identity;
$avatar = $identity && $identity->photo ? Url::attachmentUrl($identity->photo) : Url::getBackendDefaultAvatar(false, true);

$viewTheme = $this->params['uiTheme'] ?? null;
$appLogo = $viewTheme == 'ym2-theme-black' ? App::params('admin.brandLogoLight') : App::params('admin.brandLogoDark');
$appBrandName = App::params('admin.brandName');

?>
    <li class="ym2-nav-header">
        <div class="ym2-brand px-2">
            <!--<div class="ym2-brand-content anim-sort-in">-->
            <div class="ym2-brand-content">
<?php if (empty($appLogo)): ?>
                <?= $appBrandName ?>
<?php else: ?>
                <img src="<?= $appLogo ?>" style="max-width: 100%;" alt="<?= $appBrandName ?>">
<?php endif; ?>
            </div>
        </div>
        <div class="ym2-personal p-3">
            <!--<div class="img-item anim-spin-infinite">-->
            <div class="img-item">
                <!--<img ym2-full-image style="cursor: zoom-in;" alt>-->
                <img src="<?= $avatar ?>" alt>
            </div>
            <div class="pl-2">
                <p class="f14 p-content pb-2" style="font-family: 'Cascadia Code', 'PingFangSC-Regular', sans-serif;"><?= $identity->username ?></p>
                <p class="f12 p-content badge badge-primary font-weight-normal" style="font-family: 'Cascadia Code', 'PingFangSC-Regular', sans-serif;">
                    <?= SystemGroupService::getNameById($identity->group) ?>
                </p>
            </div>
        </div>
    </li>
